home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / CDTools / MUIRexx / demos / MUIRexxDir / file.rexx < prev    next >
OS/2 REXX Batch file  |  1996-04-30  |  3KB  |  85 lines

  1. /*
  2.  
  3. Code:       file.rexx
  4. Author:     Russell Leighton
  5. Revision:   11 Jan 1996
  6.  
  7. Comments:   This is script used to perform file copy, rename and move 
  8. operations.
  9.  
  10. */
  11.  
  12. options results
  13. signal on error
  14.  
  15. parse arg portname' 'ndir' 'ctype' 'sfile';'dfile
  16.  
  17. address VALUE portname
  18.  
  19. select
  20.  
  21. /* rename file (and associated icon if appropriate) from source to destination */
  22.  
  23.     when ctype = 1 then do
  24.         if exists(dfile) then do
  25.             address command 'delete > T:err "'dfile'" ALL QUIET'
  26.             list ID HST NODUP INSERT UPDATE STRING 'delete 'dfile' ALL QUIET'
  27.         end
  28.         address command 'rename > T:err "'sfile'" to "'dfile'" QUIET'
  29.         list ID HST NODUP INSERT UPDATE STRING 'rename 'sfile' to 'dfile' QUIET'
  30.         check ID ICN||ndir
  31.         if result = '1' & exists(sfile'.info') then do
  32.             if exists(dfile'.info') then do
  33.                 address command 'delete > T:err "'dfile'.info" ALL QUIET'
  34.                 list ID HST NODUP INSERT UPDATE STRING 'delete 'dfile'.info ALL QUIET'
  35.             end
  36.             address command 'rename > T:err "'sfile'.info" to "'dfile'.info" QUIET'
  37.             list ID HST NODUP INSERT UPDATE STRING 'rename 'sfile'.info to 'dfile'.info QUIET'
  38.         end
  39.     end
  40.  
  41. /* move file (and associated icon if appropriate) from source to destination */
  42.  
  43.     when ctype = 2 then do
  44.         address command 'copy > T:err "'sfile'" to "'dfile'" ALL CLONE QUIET'
  45.         list ID HST NODUP INSERT UPDATE STRING 'copy 'sfile' to 'dfile' ALL CLONE QUIET'
  46.         address command 'delete > T:err "'sfile'" ALL QUIET'
  47.         list ID HST NODUP INSERT UPDATE STRING 'delete 'sfile' ALL QUIET'
  48.         check ID ICN||ndir
  49.         if result = '1' & exists(sfile'.info') then do
  50.             address command 'copy > T:err "'sfile'.info" to "'dfile'.info" ALL CLONE QUIET'
  51.             list ID HST NODUP INSERT UPDATE STRING 'copy 'sfile'.info to 'dfile'.info ALL CLONE QUIET'
  52.             address command 'delete > T:err "'sfile'.info" ALL QUIET'
  53.             list ID HST NODUP INSERT UPDATE STRING 'delete 'sfile'.info ALL QUIET'
  54.         end
  55.     end
  56.  
  57. /* copy file (and associated icon if appropriate) from source to destination */
  58.  
  59.     when ctype = 3 then do
  60.         address command 'copy > T:err "'sfile'" to "'dfile'" ALL CLONE QUIET'
  61.         list ID HST NODUP INSERT UPDATE STRING 'copy 'sfile' to 'dfile' ALL CLONE QUIET'
  62.         check ID ICN||ndir
  63.         if result = '1' & exists(sfile'.info') then do
  64.             address command 'copy > T:err "'sfile'.info" to "'dfile'.info" ALL CLONE QUIET'
  65.             list ID HST NODUP INSERT UPDATE STRING 'copy 'sfile'.info to 'dfile'.info ALL CLONE QUIET'
  66.         end
  67.     end
  68.     otherwise nop
  69. end
  70. if exists('T:err') then address command 'delete T:err quiet'
  71. exit
  72.  
  73.  
  74. /* if an error occurs then display it */
  75.  
  76. error:
  77.     if exists('T:err') then do
  78.         call open('err','T:err')
  79.         err = readln('err')
  80.         call close('err')
  81.         address command 'delete T:err quiet'
  82.         request ID MDIR TITLE '" "' GADGETS '"OK"' '"'err'"'
  83.     end
  84. exit
  85.